<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.12.4.js"></script>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            margin: 50px 50px;
            width: 800px;
            height: 460px;
            position: relative;
        }
        .box-img{
            top: 0;
            left: 0;
            opacity: 0;
            float: left;
            position: absolute;
            background-size: 100%;
            transition: 0.5s linear;
        }
        .box-img:nth-child(1){
            opacity: 1;
        }
        .box-left, .box-right{
            width: 35px;
            height: 50px;
            background-color: darkcyan;
            color: #cccccc;
            top: 195px;
            border-radius: 5px;
            text-align: center;
            line-height: 50px;
            font-size: 30px;
            font-weight: 600;
            position: absolute;
            box-sizing: border-box;
        }
        .box-left:hover, .box-right:hover{
            background-color: cadetblue;
            color: crimson;
        }
        .box-left{
            left: 5px;
        }
        .box-right{
            right: 5px;
        }
        .box-zhili{
            bottom: 20px;
            right: 40px;
            position: absolute;
        }
        .box-zhili li{
            width: 18px;
            height: 18px;
            list-style: none;
            background-color: crimson;
            color: white;
            border-radius: 50%;
            float: left;
            margin-right: 15px;
        }
        .box-zhili li:nth-child(1){
            background-color: white;
        }
        .box-zhili li:hover{
            background-color: cadetblue;
            color: coral;
            background:white;
        }

    </style>
</head>
<body>
<div class="box">
    <div class="box-img"><img src="img/01.jpg" width="800px" height="460px"></div>
    <div class="box-img"><img src="img/02.jpg" width="800px" height="460px"></div>
    <div class="box-img"><img src="img/06.jpg" width="800px" height="460px"></div>
    <div class="box-img"><img src="img/04.jpg" width="800px" height="460px"></div>
    <div class="box-img"><img src="img/05.jpg" width="800px" height="460px"></div>
    <div class="box-left">&lt</div>
    <div class="box-right">&gt</div>
    <div class="box-zhili">
        <ul>
            <li class="button"></li>
            <li class="button"></li>
            <li class="button"></li>
            <li class="button"></li>
            <li class="button"></li>
        </ul>
    </div>
</div>
<script>
$(function () {
    var index=0;
    var f;
    dinshiqi();
    function dinshiqi(){
        f=setInterval(function () {
            index++;
            if (index==$(".box-img").length){
                index=0;
                $(".box-img").css("opacity","0")
                $(".box-img").eq(index).css("opacity","1");
                $(".button").css("background","crimson")
                $(".button").eq(index).css("background","white");
            } else {
                $(".box-img").css("opacity","0")
                $(".box-img").eq(index).css("opacity","1");
                $(".button").css("background","crimson")
                $(".button").eq(index).css("background","white");
            }

        },2000);
    }
  /*  var f=setInterval(function () {
        index++;
        if (index==$(".box-img").length-1){
            index=0;
            $(".box-img").css("opacity","0")
            $(".box-img").eq(index).css("opacity","1")
        } else {
            $(".box-img").css("opacity","0")
            $(".box-img").eq(index).css("opacity","1")
        }

    },2000);*/
    $(".box-left").click(function () {
       clearInterval(f);
        if (index==0){
            index = $(".box-img").length-1;
            $(".box-img").css("opacity","0");
            $(".box-img").eq(index).css("opacity","1");
            $(".button").css("background","crimson")
            $(".button").eq(index).css("background","white");
            dinshiqi();
        }else {
            index--;
            $(".box-img").css("opacity","0");
            $(".box-img").eq(index).css("opacity","1");
            $(".button").css("background","crimson")
            $(".button").eq(index).css("background","white");
            dinshiqi();
        }

    })
    $(".box-right").click(function () {
        clearInterval(f);
        if (index==$(".box-img").length-1){
            index=0;
            $(".box-img").css("opacity","0");
            $(".box-img").eq(index).css("opacity","1");
            $(".button").css("background","crimson")
            $(".button").eq(index).css("background","white");
            dinshiqi();
        }else {
            index++;
            $(".box-img").css("opacity","0");
            $(".box-img").eq(index).css("opacity","1");
            $(".button").css("background","crimson")
            $(".button").eq(index).css("background","white");
            dinshiqi();
        }
    });

    $(".button").click(function () {
        clearInterval(f);
       var indexxx=$(this).index();
        index =indexxx
        $(".box-img").css("opacity","0");
        $(".box-img").eq(index).css("opacity","1");
        $(".button").css("background","crimson")
        $(".button").eq(index).css("background","white");
        dinshiqi();
    })
})
</script>
</body>
</html>